package com.kexuexiong.demo.bear.mq.consumer;

import com.kexuexiong.demo.bear.mq.EnhanceMessageHandler;
import com.kexuexiong.demo.bear.mq.MemberMessage;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@RocketMQMessageListener(
        consumerGroup = "enhance_consumer_group",
        topic = "rocket_enhance",
        selectorExpression = "*",
        consumeThreadNumber = 5
)
public class EnhanceMemberMessageListener extends EnhanceMessageHandler<MemberMessage> implements RocketMQListener<MemberMessage> {

    @Override
    protected void handleMessage(MemberMessage message) throws Exception {
        log.info("handleMessage,memberMessage:{}",message);
    }

    @Override
    protected void handleMaxRetriesExceeded(MemberMessage message) {
        log.info("handleMaxRetriesExceeded,memberMessage:{}",message);
    }

    @Override
    protected boolean isRetry() {
        return true;
    }

    @Override
    protected boolean throwException() {
        return false;
    }

    @Override
    public void onMessage(MemberMessage message) {
        super.dispatchMessage(message);
    }
}
